<html>
	<script type="text/javascript" src="../../../library/jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('.5tgbnhy6').each( function() {
				$(this).remove();
			});
			addRow();
		}); 
		function guidGenerator() {
	    	var S4 = function() {
	       		return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
	    	};
	    	return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
		}
		function addRow()
		{
			guidVal = guidGenerator();
			this.$ddObj = $('<dd>');
			this.$nameLabel = $('<label class="' + guidVal + '">Name </label>');
			this.$ddObj.append(this.$nameLabel);
			this.$formFields = $('<input type="text" class="'+ guidVal +'" name="name#' + guidVal + '"/><label class="' + guidVal +'"> Value </label>');
			this.$formFields.append($('<input type="text" class="' + guidVal + '"name="value#' + guidVal +'"/>'));
			this.$ddObj.append(this.$formFields);
			this.$ddObj.append($('<input type="button" class="'+ guidVal +'" onClick="removeRow(\''+guidVal+'\');" value="Delete"/>'));
			this.$ddObj.append($('</dd>'));
			$('#metadataDL').append(this.$ddObj);
		}

		function removeRow(victimClass)
		{
			$('.' + victimClass).each( function() {
					$(this).remove();
				}
			);
		}
	</script>
	<body>
		<form method='post' action='metadata/add'>
			<input type='hidden' name='imageID' id='imageIDval' value='<?= $this->imageid; ?>'/>
			<input type='button' onClick='addRow();' value='Add Fields'/>
			<input type='submit' value='OK'/>
			<dl id='metadataDL'>
				<dt></dt>
				<dd class = '5tgbnhy6'><?=$this->form->name->getLabel() . $this->form->name ?>
				<?= $this->form->value->getLabel() . $this->form->value?>
				<input type='button' class = '5tgbnhy6' onClick='removeRow("5tgbnhy6");' value='Delete'/>
				</dd>
			</dl>
		</form>
	</body>
</html>